* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f8f9fa;
    padding: 20px;
}

.header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.back-btn-nav {
    justify-self: start;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #07c160; /* 微信绿 */
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn-nav:hover {
    color: #059d4e; /* 微信绿的深色版本 */
}

.header h1 {
    text-align: center;
    grid-column: 2;
    color: #000000; /* 黑色 */
    font-size: 20px; /* 调整字体大小 */
}

.upload-btn {
    justify-self: end;
    grid-column: 3;
}

.upload-btn {
    padding: 10px 15px;
    background-color: #07c160; /* 微信绿 */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.upload-btn:hover {
    background-color: #059d4e; /* 微信绿的深色版本 */
}

/* 禁用按钮样式 */
.upload-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.gallery-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* 小屏幕设备 (手机) */
@media (max-width: 480px) {
    .gallery-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 中等屏幕设备 (平板) */
@media (min-width: 481px) and (max-width: 1024px) {
    .gallery-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* 大屏幕设备 (桌面) */
@media (min-width: 1025px) {
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        max-width: 1200px; /* 限制最大宽度 */
        margin: 0 auto;
    }
}

/* 超大屏幕设备 */
@media (min-width: 1400px) {
    .gallery-container {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

.media-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    background-color: #eee;
    cursor: pointer;
    transition: transform 0.2s;
}

.media-item:hover {
    transform: scale(1.03);
}

.media-item img, .media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-item .delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background-color: rgba(255,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.media-item .delete-btn:hover {
    background-color: rgba(255,0,0,0.9);
}

#fileInput {
    display: none;
}